package cn.aitrox.ry.enumtype;

public enum RespCodeEnum {
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),
    LOGIN_EXPIRED(410, "登录已过期"),
    TOKEN_INVALID(411, "token验证不通过"),
    TOKEN_MISS(412, "token缺失"),
    PARAM_ERROR(420, "参数错误"),
    NO_PERMISSION(430, "无权限"),
    NOT_EXIST(440, "数据不存在"),
    EXISTED(441, "数据已存在"),
    FILE_NOT_EXISTED(442, "文件不存在"),
    FILE_EXISTED(443, "文件已存在"),
    SYS_DATA_ERROR(501, "系统数据错误"),
    SYSTEM_ERROR(-1, "系统错误");

    private Integer code;
    private String message;

    RespCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    RespCodeEnum() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static RespCodeEnum getCodeEnum(Integer code) {
        if (null == code) {
            return null;
        }
        for (RespCodeEnum respCodeEnum : RespCodeEnum.values()) {
            if (respCodeEnum.getCode().equals(code)) {
                return respCodeEnum;
            }
        }
        return null;
    }
}
